/*******************************************************************************
PaddleView.cpp

Notes:
*******************************************************************************/

#include "PaddleView.h"

// The type associated with the PaddleView class
const std::string PaddleView::Type = "Paddle";

//	PaddleView(EntityID entityID, EntityResource &entityData)
//		Sets up a PaddleView object
//			entityID - The ID of the associated entity
//			entityData - The data used to create the entity
PaddleView::PaddleView(EntityID entityID, EntityResource& entityData)
{
	// Store the entity ID
	m_entity = entityID;

	// Load the image from the file in the entity data
	m_image.LoadFromFile(entityData.GetProperty("ImageFile"));

	// Set the sprite's image to the image we just loaded
	m_sprite.SetImage(m_image);

	m_iLevel = 5;
} // PaddleView

//	Render(sf::RenderWindow& window)
//		Draws the Paddle to the screen
//			window - The SFML render window to draw to
void PaddleView::Render(sf::RenderWindow& window)
{
	float x, y, width, height;

	// Get a pointer to the associated entity
	EntityManager* pEntityMan = EntityManager::GetManager();
	Entity* pEntity = pEntityMan->GetEntity(m_entity);

	// Store the location and size of the entity
	x = pEntity->GetX();
	y = pEntity->GetY();
	width = pEntity->GetWidth();
	height = pEntity->GetHeight();

	// Change the sprite to match the entity
	m_sprite.SetX(x);
	m_sprite.SetY(y);
	m_sprite.Resize(width, height);

	// Draw the entity to the window
	window.Draw(m_sprite);
} // Render